package com.woniuxy.result;


public class Result {

    public Result() {
    }

    public Result(boolean success, String message, String code, Object data) {
        this.success = success;
        this.message = message;
        this.code = code;
        this.data = data;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    /**
     * 成功与否
     */
    private boolean success;

    /**
     * 消息
     */
    private String message;

    /**
     * 结果码
     * 0000成功
     * 1000业务异常
     * 2000系统异常
     */
    private String code;

    /**
     * 结果数据
     */
    private Object data;

    public static Result success(){
        return success(null);
    }

    public static Result success(Object data){
        return new Result(true,"执行成功","0000",data);
    }

    /**
     * 失败
     * @param code
     * @param message
     * @return
     */
    public static Result fail(String code, String message){
        return new Result(false,code,message,null);
    }
}
